package com.tjec.project.system.service.impl;

import java.util.List;

import org.apache.poi.hssf.dev.ReSave;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tjec.project.system.mapper.BmsServiceAreaMapper;
import com.tjec.project.system.domain.BmsServiceArea;
import com.tjec.project.system.service.IBmsServiceAreaService;

/**
 * sericeAreaService业务层处理
 * 
 * @author pangyongfeng
 * @date 2020-10-22
 */
@Service
public class BmsServiceAreaServiceImpl implements IBmsServiceAreaService {
	@Autowired
	private BmsServiceAreaMapper bmsServiceAreaMapper;

	/**
	 * 查询sericeArea
	 * 
	 * @param guid sericeAreaID
	 * @return sericeArea
	 */
	@Override
	public BmsServiceArea selectBmsServiceAreaByGuid(String guid) {
		BmsServiceArea res = bmsServiceAreaMapper.selectBmsServiceAreaByGuid(guid);
		if (res != null) {
			if (res.getBusiness() != null && !"".equals(res.getBusiness())) {
				String[] its = res.getBusiness().split(",");
				res.setBusinessCategoryIds(its);
			}
		}

		return res;
	}

	/**
	 * 查询sericeArea列表
	 * 
	 * @param bmsServiceArea sericeArea
	 * @return sericeArea
	 */
	@Override
	public List<BmsServiceArea> selectBmsServiceAreaList(BmsServiceArea bmsServiceArea) {
		List<BmsServiceArea> resList = bmsServiceAreaMapper.selectBmsServiceAreaList(bmsServiceArea);
		if (resList != null && resList.size() > 0) {
			resList.forEach(item -> {
				if (item.getBusiness() != null && !"".equals(item.getBusiness())) {
					String[] its = item.getBusiness().split(",");
					item.setBusinessCategoryIds(its);
				}
			});
		}
		return resList;
	}

	/**
	 * 新增sericeArea
	 * 
	 * @param bmsServiceArea sericeArea
	 * @return 结果
	 */
	@Override
	public int insertBmsServiceArea(BmsServiceArea bmsServiceArea) {
		return bmsServiceAreaMapper.insertBmsServiceArea(bmsServiceArea);
	}

	/**
	 * 修改sericeArea
	 * 
	 * @param bmsServiceArea sericeArea
	 * @return 结果
	 */
	@Override
	public int updateBmsServiceArea(BmsServiceArea bmsServiceArea) {
		return bmsServiceAreaMapper.updateBmsServiceArea(bmsServiceArea);
	}

	/**
	 * 批量删除sericeArea
	 * 
	 * @param guids 需要删除的sericeAreaID
	 * @return 结果
	 */
	@Override
	public int deleteBmsServiceAreaByGuids(String[] guids) {
		return bmsServiceAreaMapper.deleteBmsServiceAreaByGuids(guids);
	}

	/**
	 * 删除sericeArea信息
	 * 
	 * @param guid sericeAreaID
	 * @return 结果
	 */
	@Override
	public int deleteBmsServiceAreaByGuid(String guid) {
		return bmsServiceAreaMapper.deleteBmsServiceAreaByGuid(guid);
	}

	@Override
	public int checkCounts(BmsServiceArea bmsServiceArea) {
		int res = bmsServiceAreaMapper.checkCounts(bmsServiceArea);
		return res;
	}
}
